package com.starlink.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.lop.open.api.sdk.domain.ECAP.CommonQueryOrderApi.commonGetOrderTraceV1.CommonOrderTraceDetail;
import com.lop.open.api.sdk.domain.ECAP.CommonQueryOrderApi.commonGetOrderTraceV1.CommonOrderTraceResponse;
import com.lop.open.api.sdk.domain.jdcloudprint.PullDataService.pullData.PrePrintDataInfo;
import com.starlink.client.jd.vo.PrintPullDataVO;
import com.starlink.common.annotation.client.weixin.UserPurchaseRes;
import com.starlink.model.domain.MallBooksOrderDO;
import com.starlink.model.request.MallBooksOrderRequest;
import com.starlink.model.request.mall.*;
import com.starlink.model.vo.MallBooksOrderVO;
import com.starlink.model.vo.book.MallArticlesBuyVO;
import com.starlink.model.vo.mall.*;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Map;

/**
 * @author zhanghong
 */
public interface MallOrderService extends IService<MallBooksOrderDO> {

    /**
     * 根据主键查询
     * @param id
     * @return
     */
    MallBooksOrderVO getByKey(long id);
    /**
     * 分页查询，手动分页
     * @param request
     * @return
     */
    PageInfo<MallBooksOrderVO> pageQuery(Pageable pageable, MallBooksOrderRequest request);
    /**
     * 列表查询
     * @param request
     * @return
     */
    List<MallBooksOrderVO> listQuery(MallBooksOrderRequest request);
    /**
     * 新增
     * @param request
     * @return
     */
    Boolean add(MallBooksOrderRequest request);
    /**
     * 根据主键更新
     * @param request
     * @return
     */
    Boolean updateByKey(MallBooksOrderRequest request);
    /**
     * 根据主键删除
     * @param ids
     * @return
     */
    Boolean deleteDOByIds(String ids);

    /**
     * 立即购买查询
     * @param request
     * @return
     */
    MallArticlesBuyVO selectBuy(MallBuyRequest request);

    /**
     * 下预订单
     * @param request
     * @return
     */
    UserPurchaseRes payment(MallBuyRequest request);

    /**
     * 根据商品类型于订单ID，查询对应商品ID:购买数量
     * @return
     */
    List<Map<String, Long>> selectQuantity(WechatPay wechatPay);

    /**
     * 校验库存
     * @param request
     * @return
     */
    MallArticlesBuyVO checkInventory(MallBuyRequest request);

    /**
     * 计算运费
     * @param request
     * @return
     */
    MallArticlesBuyVO calculateFreight(MallBuyRequest request);

    /**
     * 商城订单查询
     * @param request
     * @param pageable
     * @return
     */
    PageInfo<List<MallOrderListVO>> selectMallOrderList(MallOrderListRequest request, Pageable pageable);

    /**
     * 取消待付款订单
     * @param request
     * @return
     */
    Boolean cancelOrderWaitPay(MallCancelOrderRequest request);

    /**
     * 查询订单详情
     * @param request
     * @return
     */
    MallOrderDetailListVO selectOrderDetail(MallCancelOrderRequest request);

    /**
     * 查询售后商品详情
     * @param request
     * @return
     */
    WechatRefundsVO selectRefundOrderDetail(MallCancelOrderRequest request);

    PageInfo<List<AdminMallOrderListVO>> pageList(AdminMallOrderListRequest request, Pageable pageable);

    /**
     * 取消已付款待发货订单
     * @param request
     * @param wechatRefund
     * @return
     */
    WeixinRefundOrderVO cancelOrderIsPay(MallCancelOrderRequest request, WechatRefund wechatRefund);

    /**
     * 发货
     * @param request
     * @return
     */
    Boolean deliverGoods(AdminMallLogisticsRequest request);

    /**
     * 查询订单详情（管理端）
     * @param request
     * @return
     */
    AdminMallOrderDetailVO orderDetail(AdminMallOrderListRequest request);

    /**
     * 确认收货
     * @param request
     * @return
     */
    Boolean confirmGoods(MallOrderConfirmRequest request);


    /**
     * 查询运单轨迹
     * @param request
     * @return
     */
    List<CommonOrderTraceDetail> traceQuery(MallOrderConfirmRequest request);

    /**
     * 获取订单打印数据
     * @param request
     * @return
     */
    PrintPullDataVO getPullData(AdminMallOrderListRequest request);
}